package com.expdatacloud.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 超期物料重检表
 *
 * @author jie
 * @date 2020/5/14 -16:21
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OverdueMaterialVo {

    @Excel(name = "据点", height = 20, width = 30)
    private String storerkey;
    @Excel(name = "机型", height = 20, width = 30)
    private String modelname;
    @Excel(name = "品号", height = 20, width = 30)
    private String sku;
    @Excel(name = "库位", height = 20, width = 30)
    private String loc;
    @Excel(name = "数量", height = 20, width = 30)
    private String qty;
    @Excel(name = "供应商", height = 20, width = 30)
    private String lottable02;
    @Excel(name = "逻辑仓", height = 20, width = 30)
    private String lottable01;
    @Excel(name = "品名", height = 20, width = 30)
    private String descr;
    @Excel(name = "规格", height = 20, width = 30)
    private String default6;
    @Excel(name = "保质期限", height = 20, width = 30)
    private String default2;
    @Excel(name = "超保质期限天数", height = 20, width = 30)
    private String supDefault2;
    @Excel(name = "存储期限", height = 20, width = 30)
    private String default3;
    @Excel(name = "制造日期", height = 20, width = 30)
    private String lottable04;
    @Excel(name = "质检日期", height = 20, width = 30)
    private String adddate;
    @Excel(name = "超期天数", height = 20, width = 30)
    private String extradays;
    @Excel(name = "重检日期", height = 20, width = 30)
    private String reCheckDate;

    public Long getReDefault2() {
        if (StringUtils.isEmpty(reCheckDate)) {
            return null;
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        long result = 0L;
        try {

            Date date = sdf.parse(lottable04);
            Date date2 = sdf.parse(reCheckDate);
            long ts = date.getTime();
            long ts2 = date2.getTime();

            result = (ts - ts2) / (1000 * 60 * 60 * 24) + Integer.parseInt(default2);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Excel(name = "重检后保质期", height = 20, width = 30)
    private Long reDefault2;


}
